package com.battle.service.controller.web;

import com.battle.pojo.param.studyPlan.*;
import com.battle.pojo.vo.studyPlan.*;
import com.battle.service.service.in.*;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;

/**
 * web/学习计划
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/studyPlan/web")
public class StudyPlanWebController {

    private final StudyPlanService service;

    public StudyPlanWebController(StudyPlanService service) {
        this.service = service;
    }


    /**
     * 创建学习计划
     *
     * @param param
     * @return
     */
    @PostMapping("/createStudyPlan")
    public ApiResult createStudyPlan(@RequestBody @Valid CreateStudyPlanParam param) {
        service.createStudyPlan(param);
        return ApiResult.ok();
    }


    /**
     * 修改学习计划
     *
     * @param param
     */
    @PutMapping("/editStudyPlan")
    public ApiResult editStudyPlan(@RequestBody @Valid EditStudyPlanParam param) {
        service.editStudyPlan(param);
        return ApiResult.ok();
    }

    /**
     * 移除学习计划
     *
     * @param id
     */
    @DeleteMapping("/removeStudyPlan")
    public ApiResult removeStudyPlan(@RequestParam("id") Long id) {
        service.removeStudyPlan(id);
        return ApiResult.ok();
    }


    /**
     * 获取学习计划详情
     *
     * @param id
     * @return
     */
    @GetMapping("/getStudyPlan")
    public ApiResult<GetStudyPlanVo> getStudyPlan(@RequestParam("id") Long id) {
        GetStudyPlanVo vo = service.getStudyPlan(id);
        return ApiResult.ok(vo);
    }

    /**
     * 获取学习计划列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getStudyPlanList")
    public ApiResult<PageResult<GetStudyPlanListVo>> getStudyPlanList(@RequestBody GetStudyPlanListParam param) {
        PageResult<GetStudyPlanListVo> result = service.getStudyPlanList(param);
        return ApiResult.ok(result);
    }


}

